//
//  LXStatus.swift
//  weibo
//
//  Created by lixin on 16/4/20.
//  Copyright © 2016年 lixin. All rights reserved.
//

import UIKit

class LXStatus: NSObject {
    
    var created_at: String?//微博创建时间
    
    var id: Int64 = 0//微博ID
    
    var text: String?//微博内容
    
    var source: String?//微博来源
    
    var user: LXUser?//用户模型
    
    var pic_ids: [LXPicInfo]?//配图数组
    
    var retweeted_status: LXStatus?//转发微博
    
    var reposts_count: Int = 0//转发数
    
    var comments_count: Int = 0//评论数
    
    var attitudes_count: Int = 0//表态数
    
    init(dict: [String: AnyObject]) {
        
        super.init()
        
        setValuesForKeysWithDictionary(dict)
    }
    
    override func setValue(value: AnyObject?, forKey key: String) {
        
        if key == "user" {
            
            if let v = value as? [String: AnyObject] {
                
                let u = LXUser(dict: v)
                
                user = u
            }
        
        }else if key == "retweeted_status" {
            
            if let v = value as? [String: AnyObject]{
                
                let s = LXStatus(dict: v)
                
                retweeted_status = s
                
            }
        
        }else if key == "pic_urls" {
        
            if let arr = value as? [[String: AnyObject]]{
            
                var tempArr: [LXPicInfo] = [LXPicInfo]()
                
                for dic in arr {
                    
                    let picInfo = LXPicInfo(dict: dic)
                    
                    tempArr.append(picInfo)
                }
                
                pic_ids = tempArr
            }
        
        }else{
        
            super.setValue(value, forKey: key)
        }
    }
    
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {
        
    }
}
